import router from './router'
import store from "@/stores";
//白名单
const whiteList = ['/login']
//
//路由守卫
router.beforeEach((to, from, next) => {
    // console.log('to',to)
    // console.log('from',from)
    // console.log('next',next)
    // console.log('token',getToken())
    const token = store.userStore.getToken
    if (token) {
        // console.log('hastoken')
        if (to.path === '/login') {
            next({ path: '/' })
        }
        return next()
    }
    else {
        // console.log('notoken')
        if (whiteList.indexOf(to.path) !== -1) {// 在免登录白名单，直接进入
            next()
        } else {// 否则全部重定向到登录页
            next('/login')
        }
    }
})

router.afterEach(() => {

})
